//
//  CollectionViewController.m
//  Hero
//
//  Created by lanou3g on 16/5/9.
//  Copyright © 2016年 刘永庆. All rights reserved.
//

#import "CollectionViewController.h"
#import "ActivetableView.h"
#import "CollectManager.h"
#import "WebViewController.h"
#define kWidth [UIScreen mainScreen].bounds.size.width
#define kHeight [UIScreen mainScreen].bounds.size.height
@interface CollectionViewController ()<TableSelectCellDeledate>
@property (nonatomic, strong) ActivetableView *myTableView;
@property (nonatomic, strong) NSArray *dataArray;
@end

@implementation CollectionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.dataArray = [[NSMutableArray alloc]init];
    self.myTableView = [[ActivetableView alloc]initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height)];
    self.myTableView.myDelegate = self;
}
- (void)viewWillAppear:(BOOL)animated
{
    self.dataArray = [[CollectManager shareManager]selectAllArticl];
    self.myTableView.dataArray = self.dataArray.mutableCopy;
    if (self.dataArray.count == 0) {
        UIImageView *iamgeView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height)];
        iamgeView.image = [UIImage imageNamed:@"意见.png"];
        UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(kWidth / 2.8, kHeight / 1.5, 200, 30)];
        [lable setTextColor:[UIColor blueColor]];
        lable.text = @"这里什么也没有哟~~~";
        
        [self.view addSubview:iamgeView];
        [self.view addSubview:lable];
    }else{
        [self.myTableView reloadData];
        [self.view addSubview:self.myTableView];
    }
    
}

- (void)didSelectCellDeledateWithModel:(ConsultModel *)model
{
    WebViewController *webViewVC = [WebViewController new];
    webViewVC.model = model;
    [self.navigationController pushViewController:webViewVC animated:YES];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
